package com.jl.jlapp.mvp.fragment;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemChildClickListener;
import com.chad.library.adapter.base.BaseQuickAdapter.OnItemClickListener;
import com.jl.jlapp.R;
import com.jl.jlapp.adapter.ShopCartListAdapter;
import com.jl.jlapp.eneity.MessageNoReadNumModel;
import com.jl.jlapp.eneity.PostModel;
import com.jl.jlapp.eneity.ShoppingCartModel;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean.GoodsDetailsBean;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsActivitysBeanX;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsActivitysBeanX.ActivityInformationBeanX;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean.GoodsActivitysBean;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean.GoodsActivitysBean.ActivityInformationBean;
import com.jl.jlapp.eneity.ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean;
import com.jl.jlapp.mvp.activity.BaseActivity;
import com.jl.jlapp.mvp.activity.GoodsDetailActivity;
import com.jl.jlapp.mvp.activity.LoginActivity;
import com.jl.jlapp.mvp.activity.MessageCenterActivity;
import com.jl.jlapp.mvp.activity.OrderSubmitActivity;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.nets.Transformer;
import com.jl.jlapp.popu.ChooseGoodsActivityPopu;
import com.jl.jlapp.popu.ChooseGoodsSpecPopu;
import com.jl.jlapp.popu.ChooseGoodsSpecPopu.OnClickOkBtnListener;
import com.jl.jlapp.popu.ClearHistorySearhPopu;
import com.jl.jlapp.popu.ModifyNumPopu;
import com.jl.jlapp.popu.ModifyNumPopu.OnClickOkBtn;
import com.jl.jlapp.utils.Tools;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

public class ShopCartFragment extends Fragment implements OnClickListener, ChooseGoodsSpecPopu.OnClickOkBtnListener, ModifyNumPopu.OnClickOkBtn {
    private static String TAG = "ShopCartFragmentaa";
    TextView buyNumTextView;
    List<ShoppingCartModel.ResultDataBean> changeShopCartGoodsMsgList = new ArrayList();
    List<ShoppingCartModel.ResultDataBean> checkedGoodsList = new ArrayList();
    ChooseGoodsActivityPopu chooseGoodsActivityPopu;
    @BindView(R.id.choose_goods_num)
    TextView chooseGoodsNum;
    ChooseGoodsSpecPopu chooseGoodsSpecPopu;
    int chooseGoodsSpecPosition = -1;
    ClearHistorySearhPopu clearHistorySearhPopu;
    DecimalFormat df;
    int forNum = 0;
    List<ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsActivitysBeanX> goodsHasActivity = new ArrayList();
    boolean isChooseEditBtn = false;
    public OnClickListener itemclick = new OnClickListener() {
        public void onClick(View paramAnonymousView) {
            ShopCartFragment.this.clearHistorySearhPopu.dismiss();
            int[] arr = new int[ShopCartFragment.this.checkedGoodsList.size()];
            int i = 0;
            while (i < ShopCartFragment.this.checkedGoodsList.size()) {
                arr[i] = ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.checkedGoodsList.get(i)).getId();
                i += 1;
            }
            ShopCartFragment.this.deleteBatchShoppingCartById(arr, Integer.valueOf(ShopCartFragment.this.userId));
            Net.get().getShoppingCart(ShopCartFragment.this.userId)
                    .compose(Transformer.<ShoppingCartModel>switchSchedulers())
                    .subscribe(new CommonObserver<ShoppingCartModel>() {
                        @Override
                        protected void onError(String errorMsg) {

                        }

                        @Override
                        protected void onSuccess(ShoppingCartModel shoppingCartModel) {

                        }
                    });
        }
    };
    ModifyNumPopu modifyNumPopu;
    List<ShoppingCartModel.ResultDataBean> noGoodsList;
    private ProgressDialog progressDialog;
    @BindView(R.id.shop_cart_content_has_goods)
    LinearLayout shopCartContentHasGoods;
    @BindView(R.id.shop_cart_content_no_goods)
    RelativeLayout shopCartContentNoGoods;
    @BindView(R.id.shop_cart_edit_btn)
    TextView shopCartEditBtn;
    @BindView(R.id.shop_cart_edit_footer_delete_btn)
    TextView shopCartEditFooterDeleteBtn;
    @BindView(R.id.shop_cart_foot_up_btn)
    LinearLayout shopCartFootUpBtn;
    @BindView(R.id.shop_cart_footer)
    RelativeLayout shopCartFooter;
    @BindView(R.id.shop_cart_go_ms_btn)
    TextView shopCartGoMsBtn;
    ShopCartListAdapter shopCartListAdapter;
    @BindView(R.id.shop_cart_list_check_all)
    CheckBox shopCartListCheckAll;
    @BindView(R.id.shop_cart_list_footer)
    RelativeLayout shopCartListFooter;
    @BindView(R.id.shop_cart_list_recycler_view)
    RecyclerView shopCartListRecyclerView;
    @BindView(R.id.shop_cart_message)
    ImageView shopCartMessage;
    @BindView(R.id.shop_cart_return_home_btn)
    TextView shopCartReturnHomeBtn;
    @BindView(R.id.shop_cart_total_price)
    TextView shopCartTotalPrice;
    List<ShoppingCartModel.ResultDataBean> shoppingCartList;
    int userId = 0;
    View view;

    private int checkOrderSubmit() {
        int j = -1;
        int m = -1;
        int k = 0;
        int i = m;
        if (k < this.checkedGoodsList.size()) {
            int n = ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(k)).getGoodsDetails().getGoodsSpecificationDetails().get(0)).getGxcGoodsState();
            if (k == 0) {
                i = n;
            }
            do {
                k += 1;
                j = i;
                i = j;
            } while (n == j);
            i = 1;
        }
        k = i;
        if (i == -1) {
            if (j == 1) {
                k = 2;
            }
        } else {
            return k;
        }
        return 3;
    }

    private boolean isSamePreSellActivity() {
        int j = -1;
        int i = 0;
        if (i < this.checkedGoodsList.size()) {
            int m = ((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(i)).getActivityId();
            int k;
            return false;
        }
        return true;
    }

    public void OnClickOkBtn(String paramString) {
        this.buyNumTextView.setText(paramString);
        this.modifyNumPopu.dismiss();
        ShoppingCartModel.ResultDataBean localResultDataBean = (ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(this.chooseGoodsSpecPosition);
        if ((localResultDataBean.getGoodsDetails() != null) && (localResultDataBean.getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {
            int i = 0;
            while (i < localResultDataBean.getGoodsDetails().getGoodsSpecificationDetails().size()) {
                if (localResultDataBean.getGoodsSpecificationDetailsId() == ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) localResultDataBean.getGoodsDetails().getGoodsSpecificationDetails().get(i)).getId()) {
                    localResultDataBean.setGoodsNum(Integer.parseInt(paramString));
                    if (!this.isChooseEditBtn) {
                        editShoppingCartGoodsById(Integer.valueOf(localResultDataBean.getId()), Integer.valueOf(this.userId), Integer.valueOf(2), Integer.valueOf(localResultDataBean.getGoodsSpecificationDetailsId()), Integer.valueOf(localResultDataBean.getGoodsNum()));
                    }
                } else {
                    i += 1;
                    continue;
                }
                int j = 0;
                for (; ; ) {
                    if ((j >= this.changeShopCartGoodsMsgList.size()) || (((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(j)).getId() == localResultDataBean.getId())) {
                        if (j != this.changeShopCartGoodsMsgList.size()) {
                            break;
                        }
                        this.changeShopCartGoodsMsgList.add(localResultDataBean);
                        break;
                    }
                    j += 1;
                }
            }
        }
        this.shopCartListAdapter.notifyDataSetChanged();
        countGoodsAllPrice();
    }

    public void OnClickOkBtn(String paramString, Integer paramInteger) {
        this.chooseGoodsSpecPopu.dismiss();
        this.shopCartListAdapter.setCheckEditBtn(true);
        this.shopCartListAdapter.setCheckAll(this.shopCartListCheckAll.isChecked());
        this.shopCartListAdapter.setCheckedGoodsList(this.checkedGoodsList);
        this.shopCartListAdapter.setCheckedChooseGoodsSpecPopIndex(Integer.valueOf(this.chooseGoodsSpecPosition));
        this.shopCartListAdapter.setCheckedGoodsSpec(paramString);
        this.shopCartListAdapter.notifyDataSetChanged();
        ResultDataBean resultDataBean = this.shoppingCartList.get(this.chooseGoodsSpecPosition);
        if ((resultDataBean.getGoodsDetails() != null) && (resultDataBean.getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {
            int i = 0;
            if (i < resultDataBean.getGoodsDetails().getGoodsSpecificationDetails().size()) {
                if (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean.getGoodsDetails().getGoodsSpecificationDetails().get(i)).getSpecifications().equals(paramString)) {
                    ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean localGoodsSpecificationDetailsBean = (ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean.getGoodsDetails().getGoodsSpecificationDetails().get(i);
                    resultDataBean.setGoodsSpecificationDetailsId(localGoodsSpecificationDetailsBean.getId());
                    resultDataBean.setGoodsSpecificationDetailsName(paramString);
                    resultDataBean.setGoodsUnitlPrice(localGoodsSpecificationDetailsBean.getPrice());
                    if (localGoodsSpecificationDetailsBean.getGoodsDisplayPictures().size() <= 0) {
                        return;
                    }
                    resultDataBean.setGoodsPicUrl(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean.GoodsDisplayPicturesBean) localGoodsSpecificationDetailsBean.getGoodsDisplayPictures().get(0)).getPicUrl());
                } else {
                    i += 1;
                    resultDataBean.setGoodsPicUrl("");
                }
            }
        }
        int i = 0;
        if ((i >= this.changeShopCartGoodsMsgList.size()) || (((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(i)).getId() == resultDataBean.getId())) {
            if (i == this.changeShopCartGoodsMsgList.size()) {
                this.changeShopCartGoodsMsgList.add(resultDataBean);
            }
        }
        i += 1;
    }

    public void buildProgressDialog() {
        if (this.progressDialog == null) {
            this.progressDialog = new ProgressDialog(getContext());
            this.progressDialog.setProgressStyle(0);
        }
        this.progressDialog.setMessage("加载中");
        this.progressDialog.setCancelable(true);
        this.progressDialog.show();
    }

    public void cancelProgressDialog() {
        if ((this.progressDialog != null) && (this.progressDialog.isShowing())) {
            this.progressDialog.dismiss();
        }
    }

    public void countGoodsAllPrice() {
        double d = 0.0D;
        int i = 0;
        while (i < this.checkedGoodsList.size()) {
            d += ((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(i)).getGoodsUnitlPrice() * ((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(i)).getGoodsNum();
            i += 1;
        }
        if (this.checkedGoodsList.size() <= 0) {
            this.shopCartFootUpBtn.setBackgroundResource(R.color.moreText);
            this.shopCartFootUpBtn.setEnabled(false);
        } else {
            this.chooseGoodsNum.setText(this.checkedGoodsList.size() + "");
            if (d <= 1.0D) {
                return;
            }
            this.shopCartTotalPrice.setText(this.df.format(d) + "");
            this.shopCartFootUpBtn.setBackgroundResource(R.color.checkGreenColor);
            this.shopCartFootUpBtn.setEnabled(true);
        }
        this.shopCartTotalPrice.setText(Double.parseDouble(this.df.format(d)) + "");
    }

    public void decideCheckAllIsHasChoose() {
        for (int i = 0; i < this.shoppingCartList.size(); i++) {
            int j = 0;
            if ((((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails() != null) && (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {

            }
            if ((j >= ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().size()) || ((((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(j)).getId() == ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsSpecificationDetailsId()) && (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getState() == 0) && ((((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(j)).getGxcGoodsStock() > 0) || (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getZeroStock().intValue() == 1) || (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(j)).getGxcGoodsState() == 1)))) {
                if (j >= ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().size()) {
                }
                if (i == this.shoppingCartList.size()) {
                    Log.d(TAG, "checkbox不能点击了，因为都是无货的");
                    this.shopCartListCheckAll.setClickable(false);
                    this.shopCartListCheckAll.setEnabled(false);
                    this.shopCartListCheckAll.setButtonDrawable(getResources().getDrawable(R.drawable.icon_checkbox_disable));
                }
                return;
            }
            j += 1;
        }
    }

    public void decideIsHasGoodsStock() {
        this.noGoodsList = new ArrayList();
        ShoppingCartModel.ResultDataBean localResultDataBean;
        int i = 0;
        if (i < this.shoppingCartList.size()) {
            if (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails() != null) {
                int j = i;
                int k = 0;
                if (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().size() > 0) {
                    k = 0;
                }
                for (; ; ) {
                    j = i;
                    if (k < ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().size()) {
                        if (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(k)).getId() != ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsSpecificationDetailsId()) {
                        }
                        if (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getState() != 0) {
                        }
                        if ((((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getZeroStock().intValue() != 0) || (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(k)).getGxcGoodsState() != 2) || (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(k)).getGxcGoodsStock() > 0)) {
                        }
                        localResultDataBean = (ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i);
                        this.shoppingCartList.remove(i);
                        this.noGoodsList.add(localResultDataBean);
                    }
                    for (j = i - 1; ; j = i - 1) {
                        i = j + 1;
                        localResultDataBean = (ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i);
                        this.shoppingCartList.remove(i);
                        this.noGoodsList.add(localResultDataBean);
                    }
                }
            }
            localResultDataBean = (ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i);
            this.shoppingCartList.remove(i);
            this.noGoodsList.add(localResultDataBean);
        }
        i = 0;
        while (i < this.noGoodsList.size()) {
            this.shoppingCartList.add(this.noGoodsList.get(i));
            i += 1;
        }
    }

    public void deleteBatchShoppingCartById(int[] paramArrayOfInt, Integer paramInteger) {
        Net.get().deleteBatchShoppingCartById(paramInteger.intValue(), paramArrayOfInt)
                .compose(Transformer.<PostModel>switchSchedulers())
                .subscribe(new CommonObserver<PostModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(PostModel postModel) {

                    }
                });
    }

    public void deleteShoppingCartById(int paramInt, Integer paramInteger) {
        Net.get().deleteShoppingCartById(paramInteger.intValue(), paramInt)
                .compose(Transformer.<PostModel>switchSchedulers())
                .subscribe(new CommonObserver<PostModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(PostModel postModel) {

                    }
                });
    }

    public void editShoppingCartGoodsById(Integer paramInteger1, Integer paramInteger2, Integer paramInteger3, Integer paramInteger4, Integer paramInteger5) {
        Net.get().editShoppingCartGoodsById(paramInteger1.intValue(), paramInteger2.intValue(), paramInteger3.intValue(), paramInteger4.intValue(), paramInteger5.intValue())
                .compose(Transformer.<PostModel>switchSchedulers())
                .subscribe(new CommonObserver<PostModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(PostModel postModel) {

                    }
                });
    }

    public void editShoppingCartGoodsById_updateGoodsSpec(Integer paramInteger1, Integer paramInteger2, Integer paramInteger3, Integer paramInteger4, Integer paramInteger5) {
        Net.get().editShoppingCartGoodsById(paramInteger1.intValue(), paramInteger2.intValue(), paramInteger3.intValue(), paramInteger4.intValue(), paramInteger5.intValue())
                .compose(Transformer.<PostModel>switchSchedulers())
                .subscribe(new CommonObserver<PostModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(PostModel postModel) {

                    }
                });
    }

    public void getMessageNum(Integer paramInteger) {
        Net.get().getMessageNum(paramInteger.intValue())
                .compose(Transformer.<MessageNoReadNumModel>switchSchedulers())
                .subscribe(new CommonObserver<MessageNoReadNumModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(MessageNoReadNumModel messageNoReadNumModel) {

                    }
                });
    }

    public void getShoppingCartByUserId(Integer paramInteger) {
        Net.get().getShoppingCart(paramInteger.intValue())
                .compose(Transformer.<ShoppingCartModel>switchSchedulers())
                .subscribe(new CommonObserver<ShoppingCartModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(ShoppingCartModel shoppingCartModel) {

                    }
                });
    }

    public void initializeAdapter() {
        this.shopCartListRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
        this.shopCartListAdapter = new ShopCartListAdapter(R.layout.shop_cart_list_item, this.shoppingCartList);
        this.shopCartListRecyclerView.setAdapter(this.shopCartListAdapter);
        setAdapterListener(this.shopCartListAdapter);
    }

    public void onClick(View paramView) {
        Intent localIntent;
        int[] arr;
        int i;
        int j;
        switch (paramView.getId()) {
            case R.id.shop_cart_list_check_all:
                this.checkedGoodsList.clear();
                if (this.shopCartListCheckAll.isChecked()) {
                    i = 0;
                    while (i < this.shoppingCartList.size()) {
                        if ((((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails() != null) && (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {
                            j = 0;
                            if (j < ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().size()) {
                                if ((((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(j)).getId() == ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsSpecificationDetailsId()) && (((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getState() == 0)) {
                                    if ((((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getZeroStock().intValue() != 0) || (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(j)).getGxcGoodsState() != 2)) {
                                    }
                                    if (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) this.shoppingCartList.get(i)).getGoodsDetails().getGoodsSpecificationDetails().get(j)).getGxcGoodsStock() > 0) {
                                        this.checkedGoodsList.add(this.shoppingCartList.get(i));
                                    }
                                }else {
                                    j += 1;
                                    this.checkedGoodsList.add(this.shoppingCartList.get(i));
                                }
                            }
                        }
                        i += 1;
                    }
                    this.shopCartListAdapter.setCheckAll(true);
                    this.shopCartListAdapter.setCheckedGoodsList(this.checkedGoodsList);
                    this.shopCartListAdapter.notifyDataSetChanged();
                }else {
                    countGoodsAllPrice();
                    Log.d(TAG, "checkedGoodsList.size:" + this.checkedGoodsList.size());
                    this.shopCartListAdapter.setCheckAll(false);
                    this.shopCartListAdapter.setCheckedGoodsList(this.checkedGoodsList);
                    this.shopCartListAdapter.notifyDataSetChanged();
                }
            case R.id.shop_cart_edit_btn:
                if (this.shopCartEditBtn.getText().toString().equals("编辑")) {
                    this.isChooseEditBtn = true;
                    this.changeShopCartGoodsMsgList.clear();
                    this.shopCartEditFooterDeleteBtn.setVisibility(View.VISIBLE);
                    this.shopCartListFooter.setVisibility(View.GONE);
                    this.checkedGoodsList.clear();
                    this.shopCartListCheckAll.setChecked(false);
                    this.shopCartEditBtn.setText("完成");
                    this.shopCartListAdapter.setCheckedGoodsList(this.checkedGoodsList);
                    this.shopCartListAdapter.setCheckEditBtn(true);
                    this.shopCartListAdapter.setCheckAll(false);
                    this.shopCartListAdapter.notifyDataSetChanged();
                    return;
                }
                this.isChooseEditBtn = false;
                this.shopCartEditFooterDeleteBtn.setVisibility(View.GONE);
                this.shopCartListFooter.setVisibility(View.VISIBLE);
                this.checkedGoodsList.clear();
                this.shopCartListCheckAll.setChecked(false);
                this.shopCartEditBtn.setText("编辑");
                this.shopCartListAdapter.setCheckedGoodsList(this.checkedGoodsList);
                this.shopCartListAdapter.setCheckEditBtn(false);
                this.shopCartListAdapter.setCheckAll(false);
                this.shopCartListAdapter.notifyDataSetChanged();
                countGoodsAllPrice();
                Log.d(TAG, "changeShopCartGoodsMsgList.size:" + this.changeShopCartGoodsMsgList.size());
                i = 0;
                while (i < this.changeShopCartGoodsMsgList.size()) {
                    Log.d(TAG, "spec:" + ((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(i)).getGoodsSpecificationDetailsName() + ", num:" + ((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(i)).getGoodsNum());
                    editShoppingCartGoodsById_updateGoodsSpec(Integer.valueOf(((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(i)).getId()), Integer.valueOf(this.userId), Integer.valueOf(-1), Integer.valueOf(((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(i)).getGoodsSpecificationDetailsId()), Integer.valueOf(((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(i)).getGoodsNum()));
                    i += 1;
                }
            case R.id.shop_cart_edit_footer_delete_btn:
                if (this.checkedGoodsList.size() > 0) {
                    i = 0;
                    if (i < this.checkedGoodsList.size()) {
                        j = 0;
                        for (; ; ) {
                            if (j < this.changeShopCartGoodsMsgList.size()) {
                                if (((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(i)).getId() == ((ShoppingCartModel.ResultDataBean) this.changeShopCartGoodsMsgList.get(j)).getId()) {
                                    this.changeShopCartGoodsMsgList.remove(j);
                                }
                            } else {
                                i += 1;
                                break;
                            }
                            j += 1;
                        }
                    }
                    this.clearHistorySearhPopu = new ClearHistorySearhPopu(getContext(), this.itemclick, Integer.valueOf(1));
                    this.clearHistorySearhPopu.showAtLocation(getActivity().findViewById(R.id.shop_cart_list_page), 17, 0, 0);
                    return;
                }
                Toast.makeText(getContext(), "你还没有选择商品!", Toast.LENGTH_SHORT).show();
                return;
            case R.id.shop_cart_foot_up_btn:
                Tools.addActivity(getActivity());
                if (this.checkedGoodsList.size() <= 0) {
                    Toast.makeText(getContext(), "你还没有选择需要结算的商品!", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (checkOrderSubmit() == 1) {
                    Toast.makeText(getContext(), "预售商品与非预售商品不能同时下单", Toast.LENGTH_SHORT).show();
                    return;
                }
                if (checkOrderSubmit() == 2) {
                    if (!isSamePreSellActivity()) {
                        Toast.makeText(getContext(), "参与不同预售活动的商品不能同时下单", Toast.LENGTH_SHORT).show();
                        return;
                    }
                    arr = new int[this.checkedGoodsList.size()];
                    i = 0;
                    while (i < this.checkedGoodsList.size()) {
                        arr[i] = ((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(i)).getId();
                        i += 1;
                    }
                    localIntent = new Intent(getActivity(), OrderSubmitActivity.class);
                    localIntent.putExtra("shopCartIds", arr);
                    localIntent.putExtra("isFromWhichPage", 0);
                    localIntent.putExtra("isPresell", 1);
                    localIntent.putExtra("activityId", ((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(0)).getActivityId());
                    startActivity(localIntent);
                    return;
                }
                arr = new int[this.checkedGoodsList.size()];
                i = 0;
                while (i < this.checkedGoodsList.size()) {
                    arr[i] = ((ShoppingCartModel.ResultDataBean) this.checkedGoodsList.get(i)).getId();
                    i += 1;
                }
                localIntent = new Intent(getActivity(), OrderSubmitActivity.class);
                localIntent.putExtra("shopCartIds", arr);
                localIntent.putExtra("isFromWhichPage", 0);
                localIntent.putExtra("isPresell", 2);
                startActivity(localIntent);
                return;
            case R.id.shop_cart_message:
                startActivity(new Intent(getContext(), MessageCenterActivity.class));
                return;
            case R.id.shop_cart_return_home_btn:
                startActivity(new Intent(getActivity(), BaseActivity.class));
                return;
        }
        if (Fragment_FirstPages.flashSaleGoodsId <= 0) {
            Toast.makeText(getActivity(), "暂时还没有限时抢购商品哦，等会儿再来看看吧~", Toast.LENGTH_SHORT).show();
            return;
        }
    }

    public View onCreateView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle) {
        this.view = paramLayoutInflater.inflate(R.layout.fragment_shop_cart, null, false);
        ButterKnife.bind(this, this.view);
        this.df = new DecimalFormat(".00");
        return this.view;
    }

    public void onResume() {
        super.onResume();
        this.userId = getContext().getSharedPreferences("JLAppData", 0).getInt("userId", 0);
        this.checkedGoodsList.clear();
        this.shopCartListCheckAll.setChecked(false);
        if (this.userId > 0) {
            this.shopCartFooter.setVisibility(View.GONE);
            this.shopCartContentNoGoods.setVisibility(View.GONE);
            this.shopCartContentHasGoods.setVisibility(View.GONE);
            getMessageNum(Integer.valueOf(this.userId));
            buildProgressDialog();
            countGoodsAllPrice();
            getShoppingCartByUserId(Integer.valueOf(this.userId));
            return;
        }
        this.shopCartMessage.setImageResource(R.drawable.icon_message_green_l);
//        Toast.makeText(getContext(), "您还未登录，请先登录。", Toast.LENGTH_SHORT).show();
//        startActivity(new Intent(getContext(), LoginActivity.class));
    }

    public void setAdapterListener(final ShopCartListAdapter paramShopCartListAdapter) {
        paramShopCartListAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            public void onItemChildClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt) {
//                ShopCartFragment.this.chooseGoodsSpecPosition = paramAnonymousInt;
//                CheckBox checkBox = paramAnonymousView.findViewById(R.id.shop_cart_list_item_checkbox);
//                do {
//                    int i;
//                    for (; ; ) {
//                        if (!checkBox.isChecked()) {
//                            ShopCartFragment.this.shopCartListCheckAll.setChecked(false);
//                            i = 0;
//                            if (i < ShopCartFragment.this.checkedGoodsList.size()) {
//                                if (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.checkedGoodsList.get(i)).getId() != ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getId()) {
//                                }
//                                ShopCartFragment.this.checkedGoodsList.remove(i);
//                            }
//                        }else  {
//                            Log.d(ShopCartFragment.TAG, "checkedGoodsList.size():" + ShopCartFragment.this.checkedGoodsList.size());
//                            ShopCartFragment.this.countGoodsAllPrice();
//                            paramShopCartListAdapter.setCheckAll(ShopCartFragment.this.shopCartListCheckAll.isChecked());
//                            paramShopCartListAdapter.setCheckedGoodsList(ShopCartFragment.this.checkedGoodsList);
//                            paramShopCartListAdapter.notifyDataSetChanged();
//                            Log.d(ShopCartFragment.TAG, "itemCheckBox.isChecked():true");
//                            ShopCartFragment.this.checkedGoodsList.add(ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt));
//                            if (ShopCartFragment.this.checkedGoodsList.size() == ShopCartFragment.this.shoppingCartList.size() - ShopCartFragment.this.noGoodsList.size()) {
//                                ShopCartFragment.this.shopCartListCheckAll.setChecked(true);
//                            } else {
//                                ShopCartFragment.this.shopCartListCheckAll.setChecked(false);
//                            }
//                        }
//                        TextView tv_reduce = (TextView) paramAnonymousView.findViewById(R.id.tv_reduce);
//                        ShoppingCartModel.ResultDataBean resultDataBean = (ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(ShopCartFragment.this.chooseGoodsSpecPosition);
//                        if ((resultDataBean.getGoodsDetails() != null) && (resultDataBean.getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {
//                            if (paramAnonymousInt < resultDataBean.getGoodsDetails().getGoodsSpecificationDetails().size()) {
//                                if (resultDataBean.getGoodsSpecificationDetailsId() == ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean.getGoodsDetails().getGoodsSpecificationDetails().get(paramAnonymousInt)).getId()) {
//                                    if (resultDataBean.getGoodsNum() > 1) {
//                                    }
//                                    Toast.makeText(ShopCartFragment.this.getContext(), "不能再减少了!", Toast.LENGTH_SHORT).show();
//                                    tv_reduce.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.moreText));
//                                }
//                                if (ShopCartFragment.this.isChooseEditBtn) {
//                                }
//                                ShopCartFragment.this.editShoppingCartGoodsById(Integer.valueOf(paramAnonymousView.getId()), Integer.valueOf(ShopCartFragment.this.userId), Integer.valueOf(0), Integer.valueOf(resultDataBean.getGoodsSpecificationDetailsId()), Integer.valueOf(resultDataBean.getGoodsNum()));
//                                i = 0;
//                                for (; ; ) {
//                                    if ((i >= ShopCartFragment.this.changeShopCartGoodsMsgList.size()) || (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.changeShopCartGoodsMsgList.get(i)).getId() == paramAnonymousView.getId())) {
//                                        if (i != ShopCartFragment.this.changeShopCartGoodsMsgList.size()) {
//                                            break;
//                                        }
////                                        ShopCartFragment.this.changeShopCartGoodsMsgList.add(paramAnonymousView);
//                                    }
//                                }
//                            }
//                        }
//                        paramShopCartListAdapter.notifyDataSetChanged();
//                        ShopCartFragment.this.countGoodsAllPrice();
//                        TextView tv_add = (TextView) paramAnonymousView.findViewById(R.id.tv_add);
//                        ShoppingCartModel.ResultDataBean resultDataBean1 = (ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(ShopCartFragment.this.chooseGoodsSpecPosition);
//                        if ((resultDataBean1.getGoodsDetails() != null) && (resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {
//                            paramAnonymousInt = 0;
//                            if (paramAnonymousInt < resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().size()) {
//                                if (resultDataBean1.getGoodsSpecificationDetailsId() == ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().get(paramAnonymousInt)).getId()) {
//                                    if (resultDataBean1.getGoodsNum() < ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().get(paramAnonymousInt)).getGxcGoodsStock()) {
//                                    }
//                                    if ((resultDataBean1.getGoodsDetails().getZeroStock().intValue() != 0) || (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().get(paramAnonymousInt)).getGxcGoodsState() != 2)) {
//                                    }
//                                    Toast.makeText(ShopCartFragment.this.getContext(), "已到库存上限!", Toast.LENGTH_SHORT).show();
//                                    tv_add.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.moreText));
//                                }
//                                for (; ; ) {
//                                    paramAnonymousInt += 1;
//                                    break;
//                                    if (resultDataBean1.getGoodsNum() >= 500) {
//                                        resultDataBean1.setGoodsNum(500);
//                                        tv_add.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.moreText));
//                                    } else {
//                                        resultDataBean1.setGoodsNum(resultDataBean1.getGoodsNum() + 1);
//                                        if (resultDataBean1.getGoodsNum() == 500) {
//                                            tv_add.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.moreText));
//                                        }
//                                        for (; ; ) {
//                                            if (ShopCartFragment.this.isChooseEditBtn) {
//                                            }
//                                            ShopCartFragment.this.editShoppingCartGoodsById(Integer.valueOf(paramAnonymousView.getId()), Integer.valueOf(ShopCartFragment.this.userId), Integer.valueOf(1), Integer.valueOf(resultDataBean1.getGoodsSpecificationDetailsId()), Integer.valueOf(resultDataBean1.getGoodsNum()));
//                                            break;
//                                            tv_add.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.trans_333333));
//                                        }
//                                        i = 0;
//                                        for (; ; ) {
//                                            if ((i >= ShopCartFragment.this.changeShopCartGoodsMsgList.size()) || (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.changeShopCartGoodsMsgList.get(i)).getId() == resultDataBean1.getId())) {
//                                                if (i != ShopCartFragment.this.changeShopCartGoodsMsgList.size()) {
//                                                    break;
//                                                }
//                                                ShopCartFragment.this.changeShopCartGoodsMsgList.add(resultDataBean1);
//                                                break;
//                                            }
//                                            i += 1;
//                                        }
//                                        if (resultDataBean1.getGoodsNum() < 500) {
//                                        }
//                                        resultDataBean1.setGoodsNum(500);
//                                        tv_add.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.moreText));
//                                    }
//                                }
//                                resultDataBean1.setGoodsNum(resultDataBean1.getGoodsNum() + 1);
//                                if (resultDataBean1.getGoodsNum() == 500) {
//                                    tv_add.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.moreText));
//                                }
//                                for (; ; ) {
//                                    if (ShopCartFragment.this.isChooseEditBtn) {
//                                    }
//                                    ShopCartFragment.this.editShoppingCartGoodsById(Integer.valueOf(paramAnonymousView.getId()), Integer.valueOf(ShopCartFragment.this.userId), Integer.valueOf(1), Integer.valueOf(resultDataBean1.getGoodsSpecificationDetailsId()), Integer.valueOf(resultDataBean1.getGoodsNum()));
//                                    break;
//                                    tv_add.setTextColor(ShopCartFragment.this.getContext().getResources().getColor(R.color.trans_333333));
//                                }
//                                i = 0;
//                                for (; ; ) {
//                                    if ((i >= ShopCartFragment.this.changeShopCartGoodsMsgList.size()) || (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.changeShopCartGoodsMsgList.get(i)).getId() == paramAnonymousView.getId())) {
//                                        if (i != ShopCartFragment.this.changeShopCartGoodsMsgList.size()) {
//                                            break;
//                                        }
//                                        ShopCartFragment.this.changeShopCartGoodsMsgList.add(resultDataBean1);
//                                        break;
//                                    }
//                                    i += 1;
//                                }
//                            }
//                        }
//                        paramShopCartListAdapter.notifyDataSetChanged();
//                        ShopCartFragment.this.countGoodsAllPrice();
//                        ShopCartFragment.this.buyNumTextView = ((TextView) paramAnonymousView.findViewById(R.id.shop_cart_goods_buy_num));
//                        if ((resultDataBean1.getGoodsDetails() != null) && (resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {
//                            paramAnonymousInt = 0;
//                            while (paramAnonymousInt < resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().size()) {
//                                if (resultDataBean1.getGoodsSpecificationDetailsId() == ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().get(paramAnonymousInt)).getId()) {
//                                    ShopCartFragment.this.modifyNumPopu = new ModifyNumPopu(ShopCartFragment.this.getActivity(), Integer.valueOf(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().get(paramAnonymousInt)).getGxcGoodsStock()), ShopCartFragment.this.buyNumTextView.getText().toString().trim(), resultDataBean1.getGoodsDetails().getZeroStock(), Integer.valueOf(((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) resultDataBean1.getGoodsDetails().getGoodsSpecificationDetails().get(paramAnonymousInt)).getGxcGoodsState()));
//                                    ShopCartFragment.this.modifyNumPopu.setOnClickOkBtn(ShopCartFragment.this);
//                                    ShopCartFragment.this.modifyNumPopu.showAtLocation(ShopCartFragment.this.getActivity().findViewById(R.id.shop_cart_list_page), 17, 0, 0);
//                                }
//                                paramAnonymousInt += 1;
//                            }
//                        }
//                    }
//                    ShopCartFragment.this.deleteShoppingCartById(((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getId(), Integer.valueOf(ShopCartFragment.this.userId));
//                    ShopCartFragment.this.shoppingCartList.remove(paramAnonymousInt);
//                    if (ShopCartFragment.this.shoppingCartList.size() <= 0) {
//                        ShopCartFragment.this.shopCartContentNoGoods.setVisibility(View.VISIBLE);
//                        ShopCartFragment.this.shopCartContentHasGoods.setVisibility(View.GONE);
//                        ShopCartFragment.this.shopCartFooter.setVisibility(View.GONE);
//                        return;
//                    }
//                    paramShopCartListAdapter.setCheckEditBtn(true);
//                    paramShopCartListAdapter.setCheckAll(ShopCartFragment.this.shopCartListCheckAll.isChecked());
//                    paramShopCartListAdapter.setCheckedGoodsList(ShopCartFragment.this.checkedGoodsList);
//                    paramShopCartListAdapter.notifyDataSetChanged();
//                    TextView tv_spec = (TextView) paramAnonymousView.findViewById(R.id.shop_cart_edit_goods_spec);
//                    if (ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt) != null) {
//                        if (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails() != null) {
//                            ShopCartFragment.this.chooseGoodsSpecPopu = new ChooseGoodsSpecPopu(ShopCartFragment.this.getActivity(), tv_spec.getText().toString().trim(), Integer.valueOf(1), ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails());
//                            ShopCartFragment.this.chooseGoodsSpecPopu.showAtLocation(ShopCartFragment.this.getActivity().findViewById(R.id.shop_cart_list_page), 80, 0, 0);
//                            ShopCartFragment.this.setChooseGoodsSpecPopuListener();
//                            return;
//                        }
//                        Toast.makeText(ShopCartFragment.this.getContext(), "获取信息出错，购物车无该商品。", Toast.LENGTH_SHORT).show();
//                        return;
//                    }
//                    Toast.makeText(ShopCartFragment.this.getContext(), "获取信息出错，购物车无该商品。", Toast.LENGTH_SHORT).show();
//                    ShopCartFragment.this.goodsHasActivity.clear();
//                    if ((ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt) != null) && (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails() != null)) {
//                        if (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsActivitys().size() > 0) {
//                            i = 0;
//                            while (i < ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsActivitys().size()) {
//                                ShopCartFragment.this.goodsHasActivity.add(((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsActivitys().get(i));
//                                i += 1;
//                            }
//                        }
//                        if (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().size() > 0) {
//                            i = 0;
//                            while (i < ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().size()) {
//                                if ((((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsSpecificationDetailsId() == ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().get(i)).getId()) && (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().get(i)).getGoodsActivitys().size() > 0)) {
//                                    int j = 0;
//                                    while (j < ((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().get(i)).getGoodsActivitys().size()) {
//                                        GoodsActivitysBean goodsActivitysBean = ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt).getGoodsDetails().getGoodsSpecificationDetails().get(i).getGoodsActivitys().get(j);
//                                        GoodsActivitysBeanX goodsActivitysBeanX = new GoodsActivitysBeanX();
//                                        goodsActivitysBean.setId(goodsActivitysBean.getId());
//                                        goodsActivitysBean.setGoodsId(goodsActivitysBean.getGoodsId());
//                                        goodsActivitysBean.setGoodsSpecificationDetails(goodsActivitysBean.getGoodsSpecificationDetails());
//                                        goodsActivitysBean.setState(goodsActivitysBean.getState());
//                                        ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsActivitysBeanX.ActivityInformationBeanX localActivityInformationBeanX = new ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsActivitysBeanX.ActivityInformationBeanX();
//                                        localActivityInformationBeanX.setId(goodsActivitysBean.getActivityInformation().getId());
//                                        localActivityInformationBeanX.setIdentifier(goodsActivitysBean.getActivityInformation().getIdentifier());
//                                        localActivityInformationBeanX.setName(goodsActivitysBean.getActivityInformation().getName());
//                                        localActivityInformationBeanX.setActivityType(goodsActivitysBean.getActivityInformation().getActivityType());
//                                        localActivityInformationBeanX.setPrice(goodsActivitysBean.getActivityInformation().getPrice());
//                                        localActivityInformationBeanX.setDiscount(goodsActivitysBean.getActivityInformation().getDiscount());
//                                        localActivityInformationBeanX.setMaxNum(goodsActivitysBean.getActivityInformation().getMaxNum());
//                                        localActivityInformationBeanX.setBeginValidityTime(goodsActivitysBean.getActivityInformation().getBeginValidityTime());
//                                        localActivityInformationBeanX.setEndValidityTime(goodsActivitysBean.getActivityInformation().getEndValidityTime());
//                                        goodsActivitysBeanX.setActivityInformation(localActivityInformationBeanX);
//                                        ShopCartFragment.this.goodsHasActivity.add(goodsActivitysBeanX);
//                                        j += 1;
//                                    }
//                                }
//                                i += 1;
//                            }
//                        }
//                    }
//                } while (ShopCartFragment.this.goodsHasActivity.size() <= 1);
//                ShopCartFragment.this.chooseGoodsActivityPopu = new ChooseGoodsActivityPopu(ShopCartFragment.this.getContext(), ShopCartFragment.this.goodsHasActivity);
//                ShopCartFragment.this.chooseGoodsActivityPopu.showAtLocation(ShopCartFragment.this.getActivity().findViewById(R.id.shop_cart_list_page), 80, 0, 0);
            }
        });
        paramShopCartListAdapter.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(BaseQuickAdapter paramAnonymousBaseQuickAdapter, View paramAnonymousView, int paramAnonymousInt) {
                if ((((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails() != null) && (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().size() > 0)) {
                    int i = 0;
                    Intent intent;
                    if (i < ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().size()) {
                        if ((((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().get(i)).getId() == ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsSpecificationDetailsId()) && (((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getState() == 0)) {
                            if ((((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getZeroStock().intValue() != 0) || (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().get(i)).getGxcGoodsState() != 2)) {
                            }
                            if (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().get(i)).getGxcGoodsStock() > 0) {
                                intent = new Intent(ShopCartFragment.this.getActivity(), GoodsDetailActivity.class);
                                intent.putExtra("goodsId", ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetailsId());
                                ShopCartFragment.this.startActivity(intent);
                            }
                        }
                        if (((ShoppingCartModel.ResultDataBean.GoodsDetailsBean.GoodsSpecificationDetailsBean) ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetails().getGoodsSpecificationDetails().get(i)).getGxcGoodsState() == 1) {
                            intent = new Intent(ShopCartFragment.this.getActivity(), GoodsDetailActivity.class);
                            intent.putExtra("goodsId", ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetailsId());
                            intent.putExtra("activityId", ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getActivityId());
                            intent.putExtra("activityName", ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getActivityName());
                            ShopCartFragment.this.startActivity(intent);
                        } else {
                            intent = new Intent(ShopCartFragment.this.getActivity(), GoodsDetailActivity.class);
                            intent.putExtra("goodsId", ((ShoppingCartModel.ResultDataBean) ShopCartFragment.this.shoppingCartList.get(paramAnonymousInt)).getGoodsDetailsId());
                            ShopCartFragment.this.startActivity(intent);
                        }
                    }
                }
            }
        });
    }

    public void setChooseGoodsSpecPopuListener() {
        this.chooseGoodsSpecPopu.setOnClickOkBtnListener(this);
    }

    public void setDataToControl() {
        if ((this.shoppingCartList != null) && (this.shoppingCartList.size() > 0)) {
            this.shopCartContentNoGoods.setVisibility(View.GONE);
            this.shopCartContentHasGoods.setVisibility(View.VISIBLE);
            this.shopCartFooter.setVisibility(View.VISIBLE);
            setListener();
            initializeAdapter();
        }
        while (this.checkedGoodsList.size() <= 0) {
            this.shopCartFootUpBtn.setBackgroundResource(R.color.moreText);
            this.shopCartFootUpBtn.setEnabled(false);
            this.shopCartMessage.setOnClickListener(this);
            this.shopCartReturnHomeBtn.setOnClickListener(this);
            this.shopCartGoMsBtn.setOnClickListener(this);
            this.shopCartFooter.setVisibility(View.GONE);
            this.shopCartContentNoGoods.setVisibility(View.VISIBLE);
            this.shopCartContentHasGoods.setVisibility(View.GONE);
        }
        this.shopCartFootUpBtn.setBackgroundResource(R.color.checkGreenColor);
        this.shopCartFootUpBtn.setEnabled(true);
    }

    public void setListener() {
        this.shopCartListCheckAll.setOnClickListener(this);
        this.shopCartEditBtn.setOnClickListener(this);
        this.shopCartEditFooterDeleteBtn.setOnClickListener(this);
        this.shopCartFootUpBtn.setOnClickListener(this);
        this.shopCartMessage.setOnClickListener(this);
        this.shopCartReturnHomeBtn.setOnClickListener(this);
        this.shopCartGoMsBtn.setOnClickListener(this);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/fragment/ShopCartFragment.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */